package com.scuec.tourismwebsite.controller;

import com.scuec.tourismwebsite.entity.FreeformPostLike;
import com.scuec.tourismwebsite.service.FreeformPostLikeService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("tour/v1")
public class FreeformPostLikeController {
    @Autowired
    private FreeformPostLikeService freeformPostLikeService;

    @GetMapping("Alike")
    public List<FreeformPostLike> selectFreeformPostLikeById(@RequestParam("user_id") int user_id, @RequestParam("post_id") int post_id){
        return freeformPostLikeService.selectFreeformPostLikeById(user_id,post_id);
    }

    @PostMapping("Alike/{user_id}/{post_id}")
    public int insertFreeformPostLike(@PathVariable("user_id") int user_id,@PathVariable("post_id") int post_id){
        return freeformPostLikeService.insertFreeformPostLike(user_id,post_id);
    }

    @DeleteMapping("Alike")
    public int deleteFreeformPostLike(@RequestParam("user_id") int user_id, @RequestParam("post_id") int post_id){
        return freeformPostLikeService.deleteFreeformPostLike(user_id,post_id);
    }
}
//1